<template>
  <div class="music-list">
    <div class="top">
      <h4 class="title">发现好歌单</h4>
      <div class="more">查看更多</div>
    </div>
    <div class="mlist">
      <router-link :to="{path: '/listview', query: {id : item.id}}" class="m-item" v-for="item in musilListInfo" :key="item.id">
        <img :src="item.picUrl" alt="">
        <span class="foot">{{ item.name }}</span>
        <span class="count">{{ parseInt(item.playCount/10000) }}万</span>
      </router-link>
    </div>
  </div>
</template>

<script>
import { getCurrentInstance, ref } from 'vue'

export default {
  setup() {
    const musilListInfo = ref([])
    const { proxy } = getCurrentInstance()

    proxy.$http.get('/personalized?limit=5').then(res => {
      if (res.code === 200) {
        musilListInfo.value = res.result
      }
    })

    return {
      musilListInfo
    }
  }
}
</script>

<style lang="less" scoped>
.music-list {
  width: 7.5rem;
  margin-top: 0.3rem;
  .top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.3rem;
    .title {
      font-size: 0.4rem;
      margin-left: 0.2rem;
    }
    .more {
      height: 0.5rem;
      width: 2rem;
      margin-right: 0.2rem;
      text-align: center;
      border: 1px solid #ccc;
      border-radius: 0.25rem;
    }
  }
  .mlist {
    width: 7.5rem;
    display: flex;
    overflow-x: auto;

    .m-item {
      display: flex;
      flex-direction: column;
      position: relative;
      width: 2.5rem;
      margin: 0.2rem 0 0.2rem 0.2rem;
      // background-color: pink;
      img {
        width: 2.5rem;
      }
      .foot {
        margin-top: 0.1rem;
        font-size: 0.3rem;
        color: #333;
      }
      .count {
        position: absolute;
        top: 0;
        right: 0;
        font-size: 0.2rem;
        color: #ccc;
      }
      .count::before {
        content: '❤ ';
      }
    }
  }
}
</style>